package com.kfm.pm;

import java.util.Random;

public class Demo04 {

    public static void main(String[] args) {
        int[] arr = new int[15];
        // 生成15个不重复的随机数放到数组中
        Random rand = new Random();
        for (int i = 0; i < arr.length; i++) {
            int number = rand.nextInt(39) + 1;
            // 判断数组中现有得数据中是否有当前的随机数
            for (int i1 = 0; i1 < i; i1++) {
                if (number == arr[i1]) {
                    number = rand.nextInt(39) + 1;
                    i1 = -1;
                }
            }
            arr[i] = number;
        }

        for (int i : arr) {
            System.out.print(i + "\t");
        }
    }
}
